package com.example.myapplication.slice;

import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.RadioButton;
import ohos.agp.components.RadioContainer;
import ohos.agp.components.Text;

public class RadioAbilitySlice extends AbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_radio);

        RadioContainer rc = (RadioContainer) findComponentById(ResourceTable.Id_sex);
        rc.setMarkChangedListener(new RadioContainer.CheckedStateChangedListener(){

            @Override
            public void onCheckedChanged(RadioContainer radioContainer, int i) {
                RadioButton componentAt = (RadioButton) radioContainer.getComponentAt(i);
                Text t  = (Text) findComponentById(ResourceTable.Id_radioText);
                t.setText(componentAt.getText()+"====>"+componentAt.isChecked()+"====>"+i);
            }
        });
    }
}
